/**
 * Copyright 2010 Creative Works, Inc.
 * Creative Works licenses this file to you under the Apache License, version
 * 2.0 (the "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *    http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.  See the License for the specific language governing
 * permissions and limitations under the License.
 */
package org.sendvox.freswitch.event;

public enum ChannelState {

	/**
	 * Channel is newly created
	 */
	CS_NEW("CS_NEW"),
	/**
	 * Channel has been initialized
	 */
	CS_INIT("CS_INIT"),
	/**
	 * Channel is looking for an extension to execute
	 */
	CS_ROUTING("CS_ROUTING"),
	/**
	 * Channel is ready to execute from 3rd party control
	 */
	CS_SOFT_EXECUTE("CS_SOFT_EXECUTE"),
	/**
	 * Channel is executing it's dialplan
	 */
	CS_EXECUTE("CS_EXECUTE"),
	/**
	 * - Channel is exchanging media with another channel.
	 */
	CS_EXCHANGE_MEDIA("CS_EXCHANGE_MEDIA"),
	/**
	 * Channel is accepting media awaiting commands.
	 */
	CS_PARK("CS_PARK"),
	/**
	 * Channel is consuming all media and dropping it
	 */
	CS_CONSUME_MEDIA("CS_CONSUME_MEDIA"),
	/**
	 * Channel is in a sleep state
	 */
	CS_HIBERNATE("CS_HIBERNATE"),
	/**
	 * Channel is in a reset state
	 */
	CS_RESET("CS_RESET"),
	/**
	 * Channel is flagged for hangup and ready to end
	 */
	CS_HANGUP("CS_HANGUP"),
	/**
	 * Channel is ready to be destroyed and out of the state machine
	 */
	CS_DONE("CS_DONE");

	private final String literal;

	private ChannelState(String literal) {
		this.literal = literal;
	}

	public String getLiteral() {
		return literal;
	}

	public static ChannelState fromLiteral(String literal) {
		for (ChannelState header : values()) {
			if (header.literal.equalsIgnoreCase(literal)) {
				return header;
			}
		}
		return null;
	}
}